package com.todo.event.activity.application.handler.activityrule;

import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author azhebuxing
 * @date 2025/1/13 15:40
 * @description
 */
@Component
public class ActivityRuleFactory implements ApplicationListener<ContextRefreshedEvent> {

    @Resource
    private BlackListHandle blackListHandle;
    @Resource
    private OperateRecordHandle operateRecordHandle;
    @Resource
    private CrowdHandle crowdHandle;
    @Resource
    private FrequencyHandle frequencyHandle;
    @Resource
    private ActivityRuleHandleChain activityRuleHandleChain;

    /**
     * ⽣成处理链
     *
     * @return
     */
    public ActivityRuleHandleChain generalRuleHandleChain() {
        return activityRuleHandleChain;
    }

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        activityRuleHandleChain.addHandler(frequencyHandle);
        activityRuleHandleChain.addHandler(operateRecordHandle);
        activityRuleHandleChain.addHandler(blackListHandle);
        activityRuleHandleChain.addHandler(crowdHandle);
    }
}
